<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="keywords" content="jquery,ui,easy,easyui,web">
	<meta name="description" content="easyui help you build your web page easily!">
	<title>体温监控系统</title>
	<jsp:include page="commons.jsp"></jsp:include>
	<style type="text/css">
		.rtitle{
			font-size:28px;
			font-weight:bold;
			padding:5px 10px;
			background:#336699;
			color:#fff;
		}
		.icon-channels{
			background:url('images/tree_channels.gif') no-repeat;
		}
		.icon-feed{
			background:url('images/rss.png') no-repeat;
		}
		.icon-rss{
			background:url('images/rss.gif') no-repeat;
		}
		#fm{
			margin:0;
			padding:10px 30px;
		}
		.ftitle{
			font-size:14px;
			font-weight:bold;
			padding:5px 0;
			margin-bottom:10px;
			border-bottom:1px solid #ccc;
		}
		.fitem{
			margin-bottom:5px;
		}
		.fitem label{
			display:inline-block;
			width:80px;
		}
		.fitem input{
			width:160px;
		}
	</style>
	<script type="text/javascript">
		$(function(){
			$('#dg').datagrid({
				onLoadSuccess:function(){
					var rows = $(this).datagrid('getRows');
					if (rows.length){
						$(this).datagrid('selectRow',0);
					}
				}
			});
			$('#t-channels').tree({
				url: 'data/channels.json',
				onSelect: function(node){
					var url = node.attributes.url;
					$('#dg').datagrid('load',{
						url: url
					});
				},
				onLoadSuccess:function(node,data){
					if (data.length){
						var id = data[0].children[0].children[0].id;
						var n = $(this).tree('find', id);
						$(this).tree('select', n.target);
					}
				}
			});
		});
	    function newUser(){
	        $('#dlg').dialog('open').dialog('setTitle','新增');
	        $('#fm').form('clear');
	        url = 'patient/save.action';
	    }
	    function editUser(){
	        var row = $('#dg').datagrid('getSelected');
	        if (row){
	        	$('#dlg').dialog('open').dialog('setTitle','修改');
	        	$('#fm').form('load',row);
	        	url = 'patient/update.action?id='+row.id;
	        }
	    }
	    function saveUser(){
	        $('#fm').form('submit',{
	        url: url,
	        onSubmit: function(){
	        return $(this).form('validate');
	        },
	        success: function(result){
	        var result = eval('('+result+')');
	        if (result.errorMsg){
	        $.messager.show({
	        title: 'Error',
	        msg: result.errorMsg
	        });
	        } else {
	        $('#dlg').dialog('close'); // close the dialog
	        $('#dg').datagrid('reload'); // reload the user data
	        }
	        }
	        });
        }
	    function destroyUser(){
	        var row = $('#dg').datagrid('getSelected');
	        if (row){
	        $.messager.confirm('确认','确认删除指定记录?',function(r){
	        if (r){
	        $.post('patient/delete.action',{id:row.id},function(result){
	        if (result.success){
	        $('#dg').datagrid('reload'); // reload the user data
	        } else {
	        $.messager.show({ // show error message
	        title: '错误',
	        msg: result.errorMsg
	        });
	        }
	        },'json');
	        }
	        });
	        }
        }
	    function showUser(){
	        var row = $('#dg').datagrid('getSelected');
	        if (row){
	        	var title=row.name;
	        	 if ($('#tt').tabs('exists', title)){
	        		 $('#tt').tabs('select', title);
        		 } else {
        			 var url="show/index.action?equipNo="+row.equipNo+"&id="+row.id;
        			 var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;"></iframe>';
	        		 $('#tt').tabs('add',{
	        		 title:title,
	        		 content:content,
	        		 closable:true
	        		 });
	        	}
	        }
	    	else{
	    		$.messager.alert('提示','请选择要查看的记录');
	    	}
        }
function reloadBedPage(pageNo,pageSize){
	var tab=$("#tt").tabs("getSelected");
	tab.panel('refresh','bed/index.action?page='+pageNo+'&rows='+pageSize);
}
</script>
</head>
<body class="easyui-layout">
	<div region="north" border="false" class="rtitle" style="height:50px;">
		体温自动监控系统
	</div>
	<div region="center" border="true">
	<div class="easyui-tabs" fit="true" id="tt">
		<div title="床位管理" data-options="href:'bed/index.action'">
		</div>
		<div title="档案管理" data-options="href:'patient/index.action'">
		</div>
		<div title="设备管理" data-options="href:'equip/index.action'">
		</div>
	</div>
	</div>
</body>
</html>